import { createRouter, createWebHistory } from 'vue-router'
import Survey from '../views/Survey.vue'
import Lottery from '../views/Lottery.vue'

const router = createRouter({
  history: createWebHistory('/mobile/'),
  routes: [
    {
      path: '/',
      redirect: '/survey'
    },
    {
      path: '/survey',
      name: 'Survey',
      component: Survey,
      meta: {
        title: '问卷调查'
      }
    },
    {
      path: '/lottery',
      name: 'Lottery',
      component: Lottery,
      meta: {
        title: '幸运抽奖'
      }
    }
  ]
})

// 设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title as string || '问卷调查'
  next()
})

export default router 